#!/bin/sh
if [ $# -ne 1 ]; then
    echo "$0 tgt"
    exit 1;
fi
tgt=`basename $1`
src=$HOME/git/$tgt

if [ `uname` == "Linux" ]; then
    dst_dir=$HOME/src/framework
elif [ `uname` == "Darwin" ]; then
    dst_dir=$HOME/job/code_svn/framework
fi

if [  -d $dst_dir/$tgt ] ; then
    str_date=$(date +'%Y-%m-%d_%H:%M:%S')
    mv $dst_dir/$tgt  $dst_dir/$tgt.$str_date.bak
fi
cp -rp $src $dst_dir

git="$dst_dir/$tgt/.git"
if [  -d "$git" ] ; then
    rm -rf "$git"
fi

build="$dst_dir/$tgt/build"
if [  -d "$build" ] ; then
    rm -r "$build"/*
fi

cd $dst_dir/$tgt
(
   svn st;
   svn ci -m "805138 $str_date svn up every morning!"
)

echo "-- Succeed,install \"$tgt\" to be \"$dst_dir/$tgt\""


